from tkinter import ttk


class ComboboxExt(ttk.Combobox):
    def __init__(self, master, dictionary={}, *args, **kw):
        ttk.Combobox.__init__(self, master, values=sorted(list(dictionary.keys()),reverse=True), *args, **kw)
        self.dictionary = dictionary
        self.bind('<<ComboboxSelected>>', self.selected)  # purely for testing purposes

    def set_dict(self, dictionary):
        self.dictionary = dictionary

        self['values'] = sorted(list(dictionary.keys()),reverse=True)

    def value(self):
        return self.dictionary[self.get()]

    def selected(self, event):  # Just to test
        pass